﻿using System;
using System.Collections.Generic;
using System.Linq; 

class Program
{
    public static void Main(string[] args)
    {
        Random random = new Random();
        List<int> randomNumbers = new List<int>();
       
        //生成100个随机数放到List里
        for (int i = 0; i < 100; i++)
        {
            int randomNumber = random.Next(0, 1001);  
            randomNumbers.Add(randomNumber);
        }

        var nums = randomNumbers
            .OrderBy(x => x);
        Console.WriteLine("排序后的数组为：");
        foreach (int i in nums)
        {
            Console.Write(i+" ");
        }
       
        int sum = nums.Sum(x => x);
        double avg=nums.Average(x => x);
       
        Console.WriteLine(Environment.NewLine+"和为" +sum);
        Console.WriteLine("平均数为" + avg);
    }

}